﻿module Supernova {

    export class Options {

        public static soundEffects: boolean = true;

        public static showStarfield: boolean = true;

        public static showOrbitLines: boolean = true;

        public static showToolTips: boolean = true;

        public static logIncomingPackets: boolean = false;

        public static load() {
            var optionsAsString = localStorage.getItem('options');
            if (optionsAsString !== null) {
                var options = JSON.parse(optionsAsString);
                if (options.soundEffects !== undefined) {
                    Options.soundEffects = <boolean>options.soundEffects;
                }
                if (options.showStarfield !== undefined) {
                    Options.showStarfield = <boolean>options.showStarfield;
                }
                if (options.showOrbitLines !== undefined) {
                    Options.showOrbitLines = <boolean>options.showOrbitLines;
                }
                if (options.showToolTips !== undefined) {
                    Options.showToolTips = <boolean>options.showToolTips;
                }
                if (options.logIncomingPackets !== undefined) {
                    Options.logIncomingPackets = <boolean>options.logIncomingPackets;
                }
            }
        }

        public static save() {
            var options = {
                soundEffects: Options.soundEffects,
                showStarfield: Options.showStarfield,
                showOrbitLines: Options.showOrbitLines,
                showToolTips: Options.showToolTips,
                logIncomingPackets: Options.logIncomingPackets
            };
            localStorage.setItem('options', JSON.stringify(options));
        }
        
    }

} 